#include "Texture.h"
#include "Game.h"
#include "Tools.h"

Texture::Texture()
{
	mTexture = 0;
	mIsTransparent = false;
}


Texture::Texture(const Texture& other)
{
}


Texture::~Texture()
{
}

bool Texture::Initialize(ID3D11ShaderResourceView* pTexture)
{
	mTexture = pTexture;

	return true;
}

bool Texture::Initialize(const std::string pFilename)
{
	HRESULT result;
	const WCHAR* filename = to_wide(pFilename);
	// Load the texture in.
	result = D3DX11CreateShaderResourceViewFromFile(CDirect3D::Instance()->GetDevice() , filename, NULL, NULL, &mTexture, NULL);
	if(FAILED(result))
	{
		return false;
	}

	if(pFilename.find("_t") != std::string::npos)
	{
		mIsTransparent = true;
	}

	return true;
}

void Texture::Uninit()
{
	if(mTexture)
	{
		mTexture->Release();
		mTexture = 0;
	}

	return;
}

ID3D11ShaderResourceView* Texture::GetTexture()
{
	return mTexture;
}

bool Texture::IsTransparent()
{
	return mIsTransparent;
}